package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.entity.NursingProject;
import com.zzyl.vo.NursingProjectVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
// Mapper接口
public interface NursingProjectMapper {
    int insertNursingProject(NursingProject nursingProject);
    int updateNursingProject(NursingProject nursingProject);
    int deleteNursingProjectById(Long id);
    NursingProject selectNursingProjectById(Long id);
    //分页条件查询
    Page<NursingProjectVo> pageQuery(@Param("name") String name,
                                     @Param("status") Integer status);
    @Select("select count(*) from nursing_project where name = #{name}")
    Integer selectByNursingProjectName(String name);

    @Select("select count(*) from nursing_project where name = #{name} and id != #{id}")
    Integer selectByNursingProjectNameForUpdate(@Param("name") String name,
                                                @Param("id") Long id);

    @Update("update nursing_project set status = #{status} where id = #{id}")
    void enableOrDisable(@Param("id") Long id, @Param("status") Integer status);
}
